package com.lebang.model;

import com.lebang.common.Util;
import com.lebangweb.common.UUIDUtil;
import lombok.Data;
import org.springframework.data.mongodb.core.mapping.Field;
import org.springframework.stereotype.Component;

import javax.servlet.http.HttpServletRequest;

/**
 * @Author: hwq
 * @Date: 2020/3/24 9:55
 * @Version 1.0
 */
@Data
@Component
public class RequestUserInfo {


    private Integer appId;
    private String appStore;

    private String brand;

    private String imei;

    private String macAddr;

    private String os;

    private String osv;

    private String memberId;

    private String version;

    private String ipAddr;

    @Field
    private String ua;


    public RequestUserInfo() {
    }

    public RequestUserInfo(HttpServletRequest request) {
        this.appStore = request.getHeader("appStore");
        this.version = request.getHeader("version");
        this.imei = request.getHeader("imei")== null ? "NoneImei:"+ UUIDUtil.NS() : request.getHeader("imei");
        this.brand = request.getHeader("brand");
        this.os = request.getHeader("os");
        this.osv = request.getHeader("osv");
        this.macAddr = request.getHeader("macAddr");
        this.memberId = request.getHeader("userid");
        this.ipAddr = Util.getIpAddress(request);
        this.ua = request.getHeader("ua") == null ? "" : request.getHeader("ua");
        this.appId = MyConfig.getEnv();
    }


}
